/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.chain.code.utils;

/**
 *
 * @author Mahdan Ahmad F A
 */
public abstract class WetLeftHand {
    
    abstract public String[] doWetLeftHand(int[][] matrix);
    
    protected int[] getNext(int startX, int startY, int direction) {
        int[] valueNext = new int[2];
        
        switch(direction) {
            case 1:
                valueNext[0] = startX - 1;
                valueNext[1] = startY - 1;
                        
                break;
            case 2:
                valueNext[0] = startX - 1;
                valueNext[1] = startY;
                
                break;
            case 3:
                valueNext[0] = startX - 1;
                valueNext[1] = startY + 1;
                
                break;
            case 4:
                valueNext[0] = startX;
                valueNext[1] = startY - 1;
                
                break;
            case 6:
                valueNext[0] = startX;
                valueNext[1] = startY + 1;
                
                break;
            case 7:
                valueNext[0] = startX + 1;
                valueNext[1] = startY - 1;
                
                break;
            case 8:
                valueNext[0] = startX  + 1;
                valueNext[1] = startY;
                
                break;
            case 9:
                valueNext[0] = startX + 1;
                valueNext[1] = startY + 1;
                
                break;
        }
        
        return valueNext;
        
    }
    
    protected int[] detectorBlack(int[][] matrix) {
        
        int[] start = new int[2];
        
        start[0] = -28;
        start[1] = -28;
        
        for (int m = 0; m < matrix.length; m++) {
            for (int n = 0; n < matrix[0].length; n++) {
                
                if (matrix[m][n] == 0 ) {
                    start[0] = m;
                    start[1] = n;
                    
                    return start;
                }
            }
        }
        
        return start;
        
    }
    
    protected int[] scanBottom(int[][] matrix, int startX, int startY) {
        int[] start = new int[2];
        
        start[0] = -28;
        start[1] = -28;
        
        for (int i = 0; i < 15; i++) {
            if (matrix[startX + 5 + i][startY + 2] == 0) {
                start[0] = startX + 5 + i;
                start[1] = startY + 2;
               
                return start;
            }
        }
        
        return start;
    }
}
